<script>
const arr = [1, 2, 3, 4, [1, 2, 3, [1, 2, 3, [1, 2, 3]]], 5, "string", { name: "弹铁蛋同学" }]

function myflat(arr){
    return arr.reduce((ar,item) => {
        return ar.concat(Array.isArray(item) ? myflat(item) : item)
    },[])
}
let flatArr = myflat(arr)

</script>